/*
 登录界面
 */
$(function(){
	"use strict";
	$('#oa_login').click(function(){
	var username=$('#username').val(),userpassword= $('#password').val(),code=$('#code').val();
		if(!username) {
			$('.loginmsg').text("用户名不能为空！");
			$('.nousername').fadeIn();
			return false;
		}else if(!userpassword){
			$('.loginmsg').text("密码不能为空！");		
			$('.nousername').fadeIn();
			return false;	
		}else if(!code){
			$('.loginmsg').text("验证码不能为空！");		
			$('.nousername').fadeIn();
			return false;
		}
		$("#oa_login").attr("disabled", true).html("正在登录中<span class='dotting '></span>");
		$.ajax({
			type:"post",
			url:'../doAdminAction.php?act=login',
			data:{
				username:username,
				password:userpassword,
				code:code
			}
		}).done(function(data){
			if(data.success === true) {
                setTimeout(function(){
					window.location.href = '../views/index.php';//登录后跳转
                },1000);
            }else{
            	setTimeout(function(){
					$('.loginmsg').text(data.msg);
					$('.nousername').fadeIn();
					$("#oa_login").attr("disabled", false).html("登录");
				},1000);
            }
		});
	
	});
});
